home *** CD-ROM | disk | FTP | other *** search
/ Micromanía: 150 Juegos 2010 / 150Juegos_16.iso / Shareware / Shape Smash / shape-smash.swf / scripts / mochi / as3 / MochiScores.as < prev    next >
Encoding:
Text File  |  2010-05-14  |  7.7 KB  |  249 lines

  1. package mochi.as3
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.text.TextField;
  5.    
  6.    public class MochiScores
  7.    {
  8.       private static var boardID:String;
  9.       
  10.       public static var onErrorHandler:Object;
  11.       
  12.       public static var onCloseHandler:Object;
  13.       
  14.       public function MochiScores()
  15.       {
  16.          super();
  17.       }
  18.       
  19.       public static function _am523() : void
  20.       {
  21.          MochiServices.send("scores_closeLeaderboard");
  22.       }
  23.       
  24.       public static function _ah51(param1:Object, param2:Object = null) : void
  25.       {
  26.          MochiServices.send("scores_getPlayerInfo",null,param1,param2);
  27.       }
  28.       
  29.       public static function _lr251(param1:Object, param2:Object = null) : void
  30.       {
  31.          MochiServices.send("scores_requestList",null,param1,param2);
  32.       }
  33.       
  34.       public static function _sh290(param1:Object = null) : void
  35.       {
  36.          if(param1 && param1.error == true && Boolean(onErrorHandler))
  37.          {
  38.             if(param1.errorCode == null)
  39.             {
  40.                param1.errorCode = "IOError";
  41.             }
  42.             onErrorHandler(param1.errorCode);
  43.             MochiServices._gp767();
  44.             return;
  45.          }
  46.          onCloseHandler();
  47.          MochiServices._gp767();
  48.       }
  49.       
  50.       public static function _ho215(param1:Object) : Object
  51.       {
  52.          var _loc2_:Object = null;
  53.          var _loc3_:Number = NaN;
  54.          var _loc4_:Number = NaN;
  55.          var _loc5_:Object = null;
  56.          var _loc6_:Object = null;
  57.          var _loc7_:String = null;
  58.          var _loc8_:String = null;
  59.          _loc2_ = {};
  60.          for(_loc7_ in param1)
  61.          {
  62.             if(typeof param1[_loc7_] == "object")
  63.             {
  64.                if(param1[_loc7_].cols != null && param1[_loc7_].rows != null)
  65.                {
  66.                   _loc2_[_loc7_] = [];
  67.                   _loc5_ = param1[_loc7_];
  68.                   _loc4_ = 0;
  69.                   while(_loc4_ < _loc5_.rows.length)
  70.                   {
  71.                      _loc6_ = {};
  72.                      _loc3_ = 0;
  73.                      while(_loc3_ < _loc5_.cols.length)
  74.                      {
  75.                         _loc6_[_loc5_.cols[_loc3_]] = _loc5_.rows[_loc4_][_loc3_];
  76.                         _loc3_++;
  77.                      }
  78.                      _loc2_[_loc7_].push(_loc6_);
  79.                      _loc4_++;
  80.                   }
  81.                }
  82.                else
  83.                {
  84.                   _loc2_[_loc7_] = {};
  85.                   for(_loc8_ in param1[_loc7_])
  86.                   {
  87.                      _loc2_[_loc7_][_loc8_] = param1[_loc7_][_loc8_];
  88.                   }
  89.                }
  90.             }
  91.             else
  92.             {
  93.                _loc2_[_loc7_] = param1[_loc7_];
  94.             }
  95.          }
  96.          return _loc2_;
  97.       }
  98.       
  99.       public static function _jh790(param1:Number, param2:String, param3:Object = null, param4:Object = null) : void
  100.       {
  101.          param1 = Number(param1);
  102.          if(isNaN(param1))
  103.          {
  104.             trace("ERROR: Submitted score \'" + String(param1) + "\' will be rejected, score is \'Not a Number\'");
  105.          }
  106.          else if(param1 == Number.NEGATIVE_INFINITY || param1 == Number.POSITIVE_INFINITY)
  107.          {
  108.             trace("ERROR: Submitted score \'" + String(param1) + "\' will be rejected, score is an infinite");
  109.          }
  110.          else
  111.          {
  112.             if(Math.floor(param1) != param1)
  113.             {
  114.                trace("WARNING: Submitted score \'" + String(param1) + "\' will be truncated");
  115.             }
  116.             param1 = Number(param1);
  117.          }
  118.          MochiServices.send("scores_submit",{
  119.             "score":param1,
  120.             "name":param2
  121.          },param3,param4);
  122.       }
  123.       
  124.       public static function _rh570(param1:Object = null) : void
  125.       {
  126.          var n:Number = NaN;
  127.          var options:Object = param1;
  128.          if(options != null)
  129.          {
  130.             delete options._cn696;
  131.             MochiServices._hp652();
  132.             MochiServices._ju656();
  133.             if(options.name != null)
  134.             {
  135.                if(options.name is TextField)
  136.                {
  137.                   if(options.name.text.length > 0)
  138.                   {
  139.                      options.name = options.name.text;
  140.                   }
  141.                }
  142.             }
  143.             if(options.score != null)
  144.             {
  145.                if(options.score is TextField)
  146.                {
  147.                   if(options.score.text.length > 0)
  148.                   {
  149.                      options.score = options.score.text;
  150.                   }
  151.                }
  152.                else if(options.score is MochiDigits)
  153.                {
  154.                   options.score = options.score.value;
  155.                }
  156.                n = Number(options.score);
  157.                if(isNaN(n))
  158.                {
  159.                   trace("ERROR: Submitted score \'" + options.score + "\' will be rejected, score is \'Not a Number\'");
  160.                }
  161.                else if(n == Number.NEGATIVE_INFINITY || n == Number.POSITIVE_INFINITY)
  162.                {
  163.                   trace("ERROR: Submitted score \'" + options.score + "\' will be rejected, score is an infinite");
  164.                }
  165.                else
  166.                {
  167.                   if(Math.floor(n) != n)
  168.                   {
  169.                      trace("WARNING: Submitted score \'" + options.score + "\' will be truncated");
  170.                   }
  171.                   options.score = n;
  172.                }
  173.             }
  174.             if(options.onDisplay != null)
  175.             {
  176.                options.onDisplay();
  177.             }
  178.             else if(MochiServices._cn696 != null)
  179.             {
  180.                if(MochiServices._cn696 is MovieClip)
  181.                {
  182.                   MochiServices._cn696.stop();
  183.                }
  184.                else
  185.                {
  186.                   trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
  187.                }
  188.             }
  189.          }
  190.          else
  191.          {
  192.             options = {};
  193.             if(MochiServices._cn696 is MovieClip)
  194.             {
  195.                MochiServices._cn696.stop();
  196.             }
  197.             else
  198.             {
  199.                trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
  200.             }
  201.          }
  202.          if(options._sh290 != null)
  203.          {
  204.             onCloseHandler = options._sh290;
  205.          }
  206.          else
  207.          {
  208.             onCloseHandler = function():void
  209.             {
  210.                if(MochiServices._cn696 is MovieClip)
  211.                {
  212.                   MochiServices._cn696.play();
  213.                }
  214.                else
  215.                {
  216.                   trace("Warning: Container is not a MovieClip, cannot call default onClose.");
  217.                }
  218.             };
  219.          }
  220.          if(options.onError != null)
  221.          {
  222.             onErrorHandler = options.onError;
  223.          }
  224.          else
  225.          {
  226.             onErrorHandler = null;
  227.          }
  228.          if(options.boardID == null)
  229.          {
  230.             if(MochiScores.boardID != null)
  231.             {
  232.                options.boardID = MochiScores.boardID;
  233.             }
  234.          }
  235.          MochiServices._cl199(options.boardID,true);
  236.          trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
  237.          MochiServices.send("scores_showLeaderboard",{"options":options},null,_sh290);
  238.       }
  239.       
  240.       public static function _no528(param1:String) : void
  241.       {
  242.          MochiServices._cl199(param1,true);
  243.          MochiScores.boardID = param1;
  244.          MochiServices.send("scores_setBoardID",{"boardID":param1});
  245.       }
  246.    }
  247. }
  248.  
  249.